<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Community_model extends CI_Model {

	function fetch_community_data($name)
	{								
		
		$data =  $this->db
						->get_where('tb_mas_community',array('strName'=>$name))
						->first_row();
						
		return $data;
						
	}
	
	function fetch_content_types()
	{								
		
		$data =  $this->db
						->get_where('tb_mas_content_types')
						->result_array();
						
		return $data;
						
	}
	
	function fetch_content($type,$cid,$limit=4,$offset=0)
	{					
		
		$data =  $this->db
						->limit($limit,$offset)
						->order_by('dteStart desc')
						->get_where('tb_mas_content',array('fk-tb_mas_content_types'=>$type,'fk-tb_mas_community'=>$cid,'enumEnabled'=>'enabled'))
						->result_array();
						
		return $data;
	}
	
	function get_featured_video($type,$cid)
	{
		$data =  $this->db						
						->order_by('dteStart desc')
						->get_where('tb_mas_content',array('fk-tb_mas_content_types'=>$type,'fk-tb_mas_community'=>$cid,'enumEnabled'=>'enabled'))
						->first_row();
						
		return $data;
	}
	
	function fetch_single_content($id)
	{						
		$data =  $this->db												
						->get_where('tb_mas_content',array('intID'=>$id,'enumEnabled'=>'enabled'))
						->result_array();
						
		return current($data);
	}
	
	function fetch_featured_image()
	{
		$data =  $this->db
						->order_by('dteDate','desc')
						->get('tb_mas_featured_image')
						->first_row();						
		return $data;
	
	}
	
	private function fetch_meta($data)
	{
		
				
	
	}

}